import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class NavigationItemWidget extends StatelessWidget {
  final String? image;
  final IconData? icon;
  final String label;
  final Widget? rightWidget;
  final Text? rightText;
  final Widget rightArrow;

  final Color iconColor;
  final TextStyle? style;
  final GestureTapCallback onTap;

  final EdgeInsets padding;
  final double iconSize;
  final double space;

  final Color? iconBackgroundColor;

  const NavigationItemWidget(
    this.label,
    this.onTap, {
    Key? key,
    this.image,
    this.icon,
    this.rightWidget,
    this.rightText,
    this.iconColor = const Color(0xff7d7d7d),
    this.style,
    this.padding = const EdgeInsets.symmetric(horizontal: 16),
    this.iconSize = 24,
    this.space = 16,
    this.iconBackgroundColor,
    this.rightArrow = const Icon(Icons.keyboard_arrow_right),
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final iconWidget = icon != null
        ? Icon(icon, size: iconSize, color: iconColor)
        : image != null
            ? Image.asset(
                image!,
                width: iconSize,
                height: iconSize,
                fit: BoxFit.cover,
              )
            : null;
    return InkWell(
      onTap: onTap,
      child: Padding(
        padding: padding,
        child: Row(
          children: <Widget>[
            if (iconWidget != null) ...[
              if (iconBackgroundColor != null)
                Container(
                  decoration: BoxDecoration(
                    color: iconBackgroundColor,
                    borderRadius: BorderRadius.all(Radius.circular(5.0)),
                  ),
                  padding: EdgeInsets.all(8.0),
                  child: iconWidget,
                )
              else
                iconWidget,
              SizedBox(width: space),
            ],
            Text(label, style:  style ?? Theme.of(context).textTheme.subtitle1),
            SizedBox(width: space),
            if (rightWidget != null) ...[
              Spacer(),
              rightWidget!,
            ] else if (rightText != null)
              Expanded(child: rightText!)
            else
              Spacer(),
            SizedBox(width: space),
            rightArrow,
          ],
        ),
      ),
    );
  }
}
